**Replication file for The Politics of Select Committee Assignments in the British House of Commons**
**Jorge M. Fernandes, Thomas Saalfeld, Carsten Schwemmer**
**Corresponding Author: Jorge M. Fernandes (jorge.fernandes@ics.ulisboa.pt)**

**The following do-file requires Stata 16 or higher**

local at1 = 0
local at2 = 0.1
local at3 = 0.2
local at4 = 0.5
local at5 = 0.9
forvalues i = 1/5{
  local at`i'_ln = ln(`at`i'' + 0.001)
}

local loy1 = 0
local loy2 = 0.05
local loy3 = 0.1
forvalues i = 1/3{
  local loy`i'_ln = ln(`loy`i'' + 0.001)
}

* Hypothesis 1
melogit committee_match pqs_committee_share_ln seniority_ln c.marginality i.GovRolePastNat c.size_vacancies i.government i.reform || mp_id:, nolog
estimates store hyp1

margins, at(pqs_committee_share_ln = (`at1_ln' `at2_ln' `at3_ln' `at4_ln' `at5_ln')) post
estimates store margins1

* Hypothesis 2
melogit committee_match c.pqs_committee_share_ln##c.comm_influence_scrutiny seniority_ln c.marginality i.GovRolePastNat c.size_vacancies i.government i.reform || mp_id:, nolog
estimates store hyp2

margins, at(pqs_committee_share_ln = (`at1_ln' `at2_ln' `at3_ln' `at4_ln' `at5_ln') comm_influence_scrutiny = (1 2 3)) post
estimates store margins2

estimates restore hyp2
margins, dydx(pqs_committee_share_ln) at(comm_influence_scrutiny = (1 2 3)) post
estimates store dydx2

* Hypothesis 3
melogit committee_match c.pqs_committee_share_ln i.government##c.rebellion_share_ln seniority_ln c.marginality i.reform i.GovRolePastNat c.size_vacancies || mp_id:
estimates store hyp3

margins, at(rebellion_share_ln = (`loy1_ln' `loy2_ln' `loy3_ln')) over(government) post
estimates store margins3

estimates restore hyp3
margins, dydx(rebellion_share_ln) over(government) post
estimates store dydx3

* Hypothesis 4 Before and After the Wright Reforms
melogit committee_match c.pqs_committee_share_ln i.government##c.rebellion_share_ln seniority_ln c.marginality i.GovRolePastNat c.size_vacancies if reform==0|| mp_id:
estimates store hyp3_Before

melogit committee_match c.pqs_committee_share_ln i.government##c.rebellion_share_ln seniority_ln c.marginality i.GovRolePastNat c.size_vacancies if reform==1|| mp_id:
estimates store hyp3_After

estimates restore hyp3_Before
margins, dydx(rebellion_share_ln) over(government) post
estimates store dydx3_Before

estimates restore hyp3_After
margins, dydx(rebellion_share_ln) over(government) post
estimates store dydx3_After


** Producing Figures **
stplot box, c(black black black)

estimates dir
estimates restore margins1

marginsplot, ///
xlabel(`at1_ln' "`at1'" `at2_ln' "`at2'" `at3_ln' "`at3'" `at4_ln' "`at4'" `at5_ln' "`at5'") ///
plotopts(mfc(white) mlw(medthin)) ///
xtitle("MPs' Policy Focus") ///
recast(scatter) ///
aspect(1) xscale(range(-7.2 0.1)) ysize(*3) xsize(*3) ///
title("") subtitle("Predicted margins with 95% CIs", size(*1.1))
graph export "h1.tif", replace width(2800) 

estimates restore margins2
marginsplot, ///
bydimension( ///
	comm_influence_scrutiny, ///
	labels("Low Desirability" "Medium Desirability" "High Desirability") ///
	) ///
xlabel(`at1_ln' "`at1'" `at2_ln' "`at2'" `at3_ln' "`at3'" `at4_ln' "`at4'" `at5_ln' "`at5'") ///
plotopts(mfc(white) mlw(medthin)) ///
xtitle("MPs' Policy Focus") ///
recast(scatter) ///
aspect(1) ysize(*3) xsize(*3) ///
byopts(ixaxes rows(1) yrescale imargin(tiny) iscale(*0.9) title(, size(*0.8)) ) ///
xtitle(, size(*0.9)) ytitle(, size(*0.9)) ///
xscale(range(-7.2 0.1))
graph export "h2.tif", replace width(2800) 

estimates restore dydx3
marginsplot, ///
recast(scatter) plotopts(mfc(white) mlw(medthin)) ///
yline(0, lp(shortdash)) ///
aspect(1) ///
xlabel(0 "Opposition" 1 "Government") xtitle("") xscale(range(-0.2 1.2)) ///
title("") subtitle("Average Marginal Effects of Rebeliousness with 95% CIs", span size(*1.1))
graph export "h3.tif", replace width(2800)

estimates restore dydx3_Before
marginsplot, ///
recast(scatter) plotopts(mfc(white) mlw(medthin)) ///
yline(0, lp(shortdash)) ///
aspect(1) ///
xlabel(0 "Opposition" 1 "Government") xtitle("") xscale(range(-0.2 1.2)) ///
title("") subtitle("Before Wright Reforms") t1title("{it:Average Marginal Effects with 95% CIs}", size(*0.9) margin(t-1))
graph save "h3_before.gph", replace

estimates restore dydx3_After
marginsplot, ///
recast(scatter) plotopts(mfc(white) mlw(medthin)) ///
yline(0, lp(shortdash)) ///
aspect(1) ///
xlabel(0 "Opposition" 1 "Government") xtitle("") xscale(range(-0.2 1.2)) ///
title("") subtitle("After Wright Reforms") t1title("{it:Average Marginal Effects with 95% CIs}", size(*0.9) margin(t-1))
graph save "h3_after.gph", replace

graph combine "h3_before.gph" "h3_after.gph"
graph export "h3_reform.tif", replace width(2800)

**********